import { Component, OnInit,Input  } from '@angular/core';
import { User } from '../../../model/User';
import { ActivatedRoute, Params } from '@angular/router';
import { UserService } from '../../../service/user.service';
import 'rxjs/add/operator/switchMap';

@Component({
  templateUrl: './user-edit.component.html',
})
export class UserEditComponent implements OnInit {

    active: boolean = true;

    user = new User();
    

    get userInfo() {
        return JSON.stringify(this.user);
    }

  constructor(private aRouter:ActivatedRoute,private  _userService:UserService ) { }

    ngOnInit() {
        let id=this.aRouter.params
        .switchMap((params: Params) => this._userService.getUserById(+params['id']) )
        .subscribe(user=>this.user=user)
     }

}